import uvicorn
from fastapi import FastAPI

from setting import setting
from src.api import router
from src.middleware import registerMiddleware

app = FastAPI(
    title="Zhijiang Dict Backend",
    docs_url=f"{setting.api_prefix}/docs" if setting.api_debug else None,
    redoc_url=f"{setting.api_prefix}/redoc" if setting.api_debug else None,
    openapi_url=f"{setting.api_prefix}/openapi.json"
)

app.include_router(router, prefix=setting.api_prefix)

registerMiddleware(app)

if __name__ == '__main__':
    uvicorn.run(
        app='main:app',
        host="0.0.0.0",
        port=3000,
        debug=setting.api_debug,
        reload=setting.api_debug,
    )
